﻿using System.Collections.Generic;
using System.Linq;
using Silent.MDB.Common.Data;
using Silent.MDB.Common.Services;

namespace Silent.MDB.Server.Model.Services
{
    public class SystemInfoServiceBase : ISystemInfoService
    {
        public List<string> GetLocations()
        {
            return ApplicationCore.AvailableLocations;
        }

        public int GetLastId(string location)
        {
            var ids = ApplicationCore.RepositoryManagers[location]
                .GetRepository<RootObject>()
                .Load(null).Select(x => x.ObjectId).ToList();

            if (ids.Any())
                return ids.Max() + 1;

            return 0;
        }
    }
}
